home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / FORTRAN Goodies / FORTRAN Speaks / Speak.f < prev    next >
Encoding:
Text File  |  1990-08-01  |  2.0 KB  |  73 lines  |  [TEXT/MPS ]

  1. C
  2. C    MacInTalk in FORTRAN demo
  3. C
  4. C    Author: Craig Vaughan
  5. C    
  6. C    This program illustrates how to use the MacInTalk driver
  7. C    from FORTRAN. Note that you must have the MacInTalk driver
  8. C    either in the same folder as the application or in your
  9. C    system folder for this application to work.
  10. C
  11. C    For licensing reasons, we do NOT supply the MacInTalk driver.
  12. C    To obtain a copy check your local user group, bulletin board or
  13. C    online service (CompuServe, America Online, GENIE, etc.).
  14. C
  15.  
  16. C Load the Toolbox inlines
  17. !!MP inlines.f
  18.     program DemoSpeak
  19.     implicit none
  20.     
  21. C Get the Types definitions
  22.     include 'Types.f'
  23.     
  24. C Get the SpeechIntf (MacInTalk) definitions
  25.     include 'SpeechIntf.f'
  26.     
  27. C Declare local variables
  28.     INTEGER*2 SpchErr , theMode, thePitch, i
  29.     STRING*255 ToSay
  30.     
  31. C Declare handles for MacInTalk
  32.     RECORD /SpeechHandle/ theSpeech
  33.     RECORD /Handle/ output
  34.  
  35. C Open the speech driver with no exceptions file
  36.     SpchErr = SpeechOn(%ref(noExcpsFiles), %ref(theSpeech))
  37.     IF (SpchErr <> 0) THEN        ! There was a problem. Let the user know
  38.         write (*,*) 'Unable to open Speech Driver. Mac OS Error:',SpchErr
  39.         STOP                    ! Get outa here!
  40.      END IF
  41.  
  42. C Set up the mode and the pitch
  43.     theMode = Natural            ! Natural speech mode
  44.     thePitch = 0                ! Normal pitch
  45.     CALL SpeechPitch(theSpeech, thePitch, theMode)
  46.  
  47. C Get a handle for translated speech. Initially 0 bytes. It will grow as required
  48.     output = NewHandle(0)
  49.     
  50. C Set the input string to something other than quit
  51.     toSay = ' '
  52.  
  53. C Keep asking for input until the user enters quit
  54.     DO WHILE (toSay<>'quit'.and.toSay<>'QUIT')
  55.         WRITE (*,*) 'What should I say? (Enter “quit” to exit)'
  56.         READ (*,*) toSay
  57.         IF (toSay<>'quit'.and.toSay<>'QUIT') THEN ! Are we quitting?
  58. C If not then say it!
  59. C Translate to phonemes
  60.             SpchErr = Reader(theSpeech, %loc(toSay)+1,len(toSay), output)
  61. C Speak the translated text
  62.             SpchErr = MacinTalk(theSpeech, output)
  63.         END IF
  64.     END DO
  65.     
  66. C Close the speech driver
  67.     CALL SpeechOff(theSpeech)
  68.  
  69. C Release the output handle
  70.     CALL DisposHandle(output)
  71.  
  72.     END
  73.